package com.atguigu.juc;

/**
 * @author:MJS
 * @create: 2022-12-22-12:01
 * @description:
 */
public class StrAndBinary {
    public static void main(String[] args){
        StrAndBinary sab = new StrAndBinary();
        String str = "中国";
        System.out.println(sab.strToBinary(str));//100111000101101101011011111101
                                                 //100111000101101101011011111101

    }

    public String strToBinary(String str){
        char[] c = str.toCharArray();
        String s = "";
        for(int i = 0; i < c.length; i++){
            int temp = c[i];
            s += Integer.toBinaryString(temp)+" ";
        }
        return s;
    }
}
